#include "stdafx.h"
#include "ResourceManager.h"

ResourceManager* ResourceManager::ourInstance = 0;

std::string ResourceManager::GetFilePath(const std::string& aFile)
{
	if(ourInstance == NULL)
	{
		ourInstance = new ResourceManager;
	}

	return ourInstance->myRelativePath + aFile;
}

bool ResourceManager::FileExists(const std::string& aFileName)
{
	DWORD hr = GetFileAttributesA(aFileName.c_str());
	if (FAILED( hr ))
	{
		return false;
	}
	return true;
}

ResourceManager::ResourceManager()
{
	if(FileExists("ResourceManager.txt"))
	{
		OS::File file;
		file.Open("ResourceManager.txt", OS::READ);
		file.ReadString(myRelativePath);
		DL_PRINT(std::string("Resource manager created with relative path: \"") + myRelativePath + "\"");
		file.Close();
	}
	else
	{
		DL_DEBUG("Resource manager created. Couldn't find ResourceManager.txt, no relative path available.");
	}
}

ResourceManager::~ResourceManager()
{

}